﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace chatblog.bbsmanage
{
    public partial class siteinfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser.dealcookie();
                dealrequest();
                bind1();
                //bind2();
                //bind3();
            }
        }
        /// <summary>
        /// 绑定
        /// </summary>
        private void bind1()
        {
            cbarea u = cbarea.Find(" cbuserid = '" + AliApi.appUserId + "'", "RECID");
            TextBox1.Text = u.cbname.ToString();
            TextBox2.Text = u.domainname1.ToString();
            TextBox3.Text = u.domainname2.ToString();
            TextBox4.Text = u.domainname3.ToString();
            TextBox5.Text = u.domainname4.ToString();
            TextBox6.Text = u.jcdesc.ToString();
            TextBox7.Text = u.googlename.ToString();
            TextBox8.Text = u.googlecontent.ToString();
            if (u.enableareabtn.Value == RuleCode.Enum.NoYes.Yes)
            {
                CheckBox1.Checked = true;
            }
            else
            {
                CheckBox1.Checked = false;
            }

            if (u.enableask.Value == RuleCode.Enum.NoYes.Yes)
            {
                CheckBox2.Checked = true;
            }
            else
            {
                CheckBox2.Checked = false;
            }
            if (u.enablepaihang.Value == RuleCode.Enum.NoYes.Yes)
            {
                CheckBox3.Checked = true;
            }
            else
            {
                CheckBox3.Checked = false;
            }
            if (u.enablegonggao.Value == RuleCode.Enum.NoYes.Yes)
            {
                CheckBox4.Checked = true;
            }
            else
            {
                CheckBox4.Checked = false;
            }
        }
        private void dealrequest()
        {
            if (AliApi.appUserId == "")
            {
                Response.Redirect(ResolveUrl("~/login/login.aspx?redirecturl=") + ResolveUrl("~/bbsmanage/siteinfo.aspx"));
            }
            cbuser us = cbuser.Find(" cbuserid = '" + AliApi.appUserId + "' ");
            HyperLink_link2.Text = "http://" + us.RECID.ToString() + ".bbs.f980.com/";
            HyperLink_link2.NavigateUrl = "http://" + us.RECID.ToString() + ".bbs.f980.com/";
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            cbarea u = cbarea.Find(" cbuserid = '" + AliApi.appUserId + "'", "RECID");
            u.cbname.Value = TextBox1.Text;
            u.cbtitle.Value = TextBox1.Text;
            u.domainname1.Value = TextBox2.Text;
            u.domainname2.Value = TextBox3.Text;
            u.domainname3.Value = TextBox4.Text;
            u.domainname4.Value = TextBox5.Text;
            u.jcdesc.Value = TextBox6.Text;
            u.googlename.Value = TextBox7.Text;
            u.googlecontent.Value = TextBox8.Text;
            if (CheckBox1.Checked == true)
            {
                u.enableareabtn.Value = RuleCode.Enum.NoYes.Yes;
            }
            else
            {
                u.enableareabtn.Value = RuleCode.Enum.NoYes.No;
            }
            if (CheckBox2.Checked == true)
            {
                u.enableask.Value = RuleCode.Enum.NoYes.Yes;
            }
            else
            {
                u.enableask.Value = RuleCode.Enum.NoYes.No;
            }
            if (CheckBox3.Checked == true)
            {
                u.enablepaihang.Value = RuleCode.Enum.NoYes.Yes;
            }
            else
            {
                u.enablepaihang.Value = RuleCode.Enum.NoYes.No;
            }
            if (CheckBox4.Checked == true)
            {
                u.enablegonggao.Value = RuleCode.Enum.NoYes.Yes;
            }
            else
            {
                u.enablegonggao.Value = RuleCode.Enum.NoYes.No;
            }
            u.Modify();
            MessageBox.Show(this.Page, "操作完成");
        }
    }
}
